<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/header.css" />
	</head>

	<body>

		<header class="mui-bar mui-bar-nav title">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
			<a id="link_correct_report" class="mui-icon mui-icon-right-nav mui-pull-right"
				style="color: white;font-size: 14px;line-height: 27px;">提交</a>
			<h1 class="mui-title title-color">实习报告查看</h1>
		</header>

		<div class="mui-content">
			<div class="mui-input-row">
				<label>标题</label>
				<input id="report_title" type="text" class="mui-input-clear" placeholder="请输入实习报告标题">
			</div>
			<div class="mui-input-row">
				<textarea rows="23" cols="20" id="report_content" style="height: 100%;"
					readonly="true"></textarea>
			</div>
			<div class="mui-input-row">
				<label>分数:</label>
				<select id="link_mark">
					<option value="不及格">不及格</option>
					<option value="及格">及格</option>
					<option value="一般">一般</option>
					<option value="良好">良好</option>
					<option value="优秀" selected>优秀</option>
				</select>
			</div>
			<div class="mui-input-row">
				<label>评语:</label>
			</div>
			<div class="mui-input-row">
				<textarea rows="15" cols="20" id="correct_content" style="height: 100%;"
					placeholder="请填写评语"></textarea>
			</div>
		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/app.js"></script>
		<script type="text/javascript">

			// 获取上一个页面传入的值
			var reportTitle;
			var reportContent;
			var reportRemark;
			var reportMark;

			mui.plusReady(function() {
				var user = app.getGlobalUserInfo();

				// 获取当前页面webview
				var reportWebview = plus.webview.currentWebview();
				
				// 获取上一个页面传入的值
				reportTitle = reportWebview.reportTitle;
				reportContent = reportWebview.reportContent;
				reportRemark = reportWebview.reportRemark;
				reportMark = reportWebview.reportMark;
				
				var link_mark = document.getElementById("link_mark");
				link_mark.value = reportMark;
				
				var report_title = document.getElementById("report_title");
				report_title.value = reportTitle;

				var report_content = document.getElementById("report_content");
				report_content.value = reportContent;

				var correct_content = document.getElementById("correct_content");
				correct_content.value = reportRemark;

				var link_correct_report = document.getElementById("link_correct_report");
				link_correct_report.addEventListener("tap",function(){
					
					var correct_content_value = correct_content.value;
					if (correct_content_value == '' || correct_content_value == null) {
						app.showToast("请输入评语！", "error");
					} else {
						mui.ajax(app.serverUrl + "/user/teacher/correct_student_report?ir_id=" + reportTitle
												+ "&ir_mark=" + link_mark.value
												+ "&ir_remark=" + correct_content_value, {
							data: {},
							dataType: 'json', //服务器返回json格式数据
							type: 'post', //HTTP请求类型
							timeout: 10000, //超时时间设置为10秒；
							headers: {
								'Content-Type': 'application/json'
							},
							success: function(data) {
								if (data.status == 200) {
									app.showToast("上传成功！", "success");
									mui.openWindow({
										url: "teacherSeeStudentReport.html", 
										id: "teacherSeeStudentReport.html",
										createNew: true
									});
								} else {
									app.showToast("获取数据失败，请重试！", "error");
								}
							}
						});
					}
					
				});
				
			});
		</script>
	</body>

</html>
